/*
 * Copyright (c) Scrap Material Junior Brother, Xin. 2023-2023. All rights reserved.
 */

package collection;

import java.util.Stack;

/**
 * 栈的相关API
 *
 * @author xin
 * @since 2023-05-02
 */
public class StackApi {
    public static void main(String[] args) {
        Stack<Character> stack = new Stack<>();
        stack.push('A');
        System.out.println(stack);
        stack.push('B');
        System.out.println(stack);
        // 查看栈顶元素，但不移除
        stack.peek();
        System.out.println(stack);
        // 移除栈顶元素
        stack.pop();
        System.out.println(stack);
        System.out.println(stack.empty());
        // 存在则返回1，否则返回-1
        System.out.println(stack.search('A'));
        System.out.println(stack.search('B'));
    }
}
